/**
 * 
 */
package br.com.cept.sce.bean;

import java.io.File;
import java.io.IOException;

import javax.faces.context.FacesContext;
import javax.servlet.ServletContext;

import com.lowagie.text.BadElementException;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.Image;
import com.lowagie.text.PageSize;

/**
 * @author Junier Amorim
 *
 */
public class RelatorioBean {
	
	
	public void preProcessPDF(Object document) throws IOException, BadElementException, DocumentException {
		Document pdf = (Document) document;
	    pdf.open();
	    pdf.setPageSize(PageSize.A4);

	    ServletContext servletContext = (ServletContext) FacesContext.getCurrentInstance().getExternalContext().getContext();
	    String logo = servletContext.getRealPath("") + File.separator + "images" + File.separator + "logo.png";
	    Image img = Image.getInstance(logo);
	    img.scalePercent(50);
	    pdf.add(Image.getInstance(img));
	}


}
